package dome1;

public class Text {
    public static int getElement(int[] arr,int index)
            throws NullPointerException,ArrayIndexOutOfBoundsException{
        if(arr == null) {
            throw new NullPointerException("传递数组为空");
        }
        if(index < 0 || index >=arr.length) {
            throw new ArrayIndexOutOfBoundsException("传递数组下标越界");
        }
        return arr[index];
    }
    public static void main(String[] args) {
//        System.out.println(10/0);
//        int[] arr = {1,2,3};
//        System.out.println(arr[3]);
//        int[] arr = null;
//        System.out.println(arr.length);
//        throw new XXXException("异常产生的原因");
    }
}
